package maopao;

import java.util.Arrays;

public class MaoPao {
    public static void main(String[] args) {
        int r;
        int[] arr = new int[10];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * 10 + 1);
        }
        System.out.println("Arrays.toString(arr) = " + Arrays.toString(arr));
        a(arr, arr.length);
    }
    //冒泡排序
    public static void a(int []arr,int r){
        for (int i = 0; i < arr.length-1; i++) {
            for (int j = 0; j < arr.length-1-i; j++) {
                if(arr[j]>arr[j+1]){
                    r=arr[j+1];
                    arr[j+1]=arr[j];
                    arr[j]=r;
                }
            }
        }
        System.out.println("Arrays.toString(arr) = " + Arrays.toString(arr));
    }
}
